﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style>
        .clickable {cursor:pointer;color:Blue}
        .res  {color:red; cursor:default}
    </style>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="Scripts/toJson.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function ()
        {
            $('.test .clickable').each(function ()
            {
                var parent = $(this).parent();
                var call = parent.attr('call');
                var resEl = $('.res', parent);
                var post = call.indexOf('?') > 0 ? call.substring(call.indexOf('?') + 1) : "";
                $(this).click(function ()
                {
                    $.ajax({
                        type: "POST",
                        url: "/Service/api.asmx/" + call,
                        contentType: "application/json; charset=utf-8",
                        data: post,
                        dataType: "json",
                        success: function (response)
                        {
                            alert(this);
                            resEl.html(JSON.stringify(response.d));
                        },
                        failure: function (msg)
                        {
                            alert('error');
                        },
                        context: 5
                    });
                });
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        
    </div>
    <div call="HelloWorld" class="test">
        <div class="clickable">Hellow World</div>
        <div class="res"></div>
    </div>

    <div call="GetFollowersByID?{'twitterID':78568659}" class="test">
        <div class="clickable">get twitter followers</div>
        <div class="res"></div>
    </div>

    <div call="GetPageByID?{'pageID':100000951109812}" class="test">
        <div class="clickable">get facebook page</div>
        <div class="res"></div>
    </div>

    <div call="GetPageFansCount?{'pageID':100000951109812}" class="test">
        <div class="clickable">get facebook page fan count</div>
        <div class="res"></div>
    </div>

    <div call="GetPageFans?{'pageID':100000951109812}" class="test">
        <div class="clickable">get facebook page fans</div>
        <div class="res"></div>
    </div>
    <div>
    </div>
    </form>
</body>
</html>
